home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
221_01
/
ccroot.asm
< prev
next >
Wrap
Assembly Source File
|
1980-01-01
|
1KB
|
60 lines
*
* root module for small-c compiler
* written by dieter flunkert
* 22 feb 1986 version A.01
* functions:
* - set up stack pointer
* - get argc and argv values
* (fetch command line)
*
EXT main
NAME CCROOT
GLOBAL CCROOT
CCROOT
LIB CCEQU.ASM
STS STACK SAVE STACK
LDS MEMEND SET NEW ONE
LEAS -2,S
LDX #LINBUF GET INPUT BUFFER ADR
LDB #1 ONE ARGUMENT ALREADY (THIS IS THE PROGRAM NAME)
CCROOT0 PSHS X SAVE ARGUMENT POINTER
LDA #13
CMPA ,X END OF INPUT?
BEQ CCROOT1 IF YES CONTINUE THERE
LDA #$20
CMPA ,X+ END OF ARGUMENT?
BNE CCROOT0+2 NO, DO IT AGAIN
CLR -1,X YES, SET END ID = \n
INCB BUMP ARGUMENT COUNTER
CMPA ,X NOW SKIP SPACES
BNE CCROOT0 NOTHING TO SKIP
LEAX 1,X ELSE ACVANCE BUFFER POINTER
BRA *-6 AND LOOP
CCROOT1 CLR ,X YES, SET END = \n
CLRA
PSHS D argc on stack
LEAX 2,S argv on stack
PSHS X
*
* rearange argument pointers
*
LEAY 4,S GET LAST ARG POINTER
LDX MEMEND AND ALSO FIRST ONE
LEAX -2,X
CCROOT2 LEAX -2,X
PSHS X
CMPY ,S++ FIRST = LAST?
BHS CCROOT3 YES, DONE
LDD ,X ELSE CHANGE ARG POINTERS
PSHS D
LDD ,Y
STD ,X
PULS D
STD ,Y++
BRA CCROOT2
CCROOT3 LBSR main
LDS STACK RESET STACK TO OLD VALUE
JMP WARMS
STACK RMB 2
END CCROOT